import z from "zod";

export const ProfileSchema = () =>
  z.object({
    image: z.string().optional(),
    name: z.string().optional(),
    first_name: z.string().optional(),
    last_name: z.string().optional(),
    address: z.string().optional(),
    region: z.string().optional(),
  });

export const PasswordSchema = () =>
  z.object({
    current_password: z.string().optional(),
    new_password: z.string().min(6, {
      message: "New password must be at least 6 characters",
    }),
    confirm_password: z.string().min(1, {
      message: "Confirm password is required",
    }),
  }).refine((data) => data.new_password === data.confirm_password, {
    message: "Passwords do not match",
    path: ["confirm_password"],
  });

export const PasswordSetSchema = () =>
  z.object({
    new_password: z.string().min(6, {
      message: "New password must be at least 6 characters",
    }),
    confirm_password: z.string().min(1, {
      message: "Confirm password is required",
    }),
  }).refine((data) => data.new_password === data.confirm_password, {
    message: "Passwords do not match",
    path: ["confirm_password"],
  });

export type ProfileFormData = z.infer<ReturnType<typeof ProfileSchema>>;
export type PasswordFormData = z.infer<ReturnType<typeof PasswordSchema>>;
